package com.gensdai.leliang.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.gensdai.leliang.R;
import com.gensdai.leliang.base.BaseActivityNoAbs;
import com.gensdai.leliang.dialog.Upload;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/8/14.
 */

public class NewUser extends BaseActivityNoAbs implements View.OnClickListener {

    @BindView(R.id.ui_title)
    TextView uiTitle;
    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.user_img)
    SimpleDraweeView userImg;
    @BindView(R.id.user_name)
    TextView userName;
    @BindView(R.id.zc)
    TextView zc;
    @BindView(R.id.gl)
    TextView gl;

    private Upload up;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_user);
        ButterKnife.bind(this);
        init();
    }


    @Override
    protected void onStart() {
        super.onStart();
        if (getSharedPreferences("User", MODE_PRIVATE).getBoolean("enter_state", false)) {
            Log.e("登录状态：", "登录");
            this.finish();
        } else {
            Log.e("登录状态：", "未登录");
        }
    }

    /**
     * 初始化
     */
    private void init() {
        uiTitle.setText("联合登录");
        userName.setText(getIntent().getStringExtra("type"));
        userImg.setImageURI(Uri.parse(getIntent().getStringExtra("url")));
        up = new Upload(this);
        back.setOnClickListener(this);
        zc.setOnClickListener(this);
        gl.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back:
                this.finish();
                break;
            case R.id.zc:
                startActivity(new Intent(this, quick_login.class));
                break;
            case R.id.gl:
                Intent intent = new Intent(this, user_enter.class);
                if (getIntent().hasExtra("QQopenid")) {
                    intent.putExtra("QQopenid", getIntent().getStringExtra("QQopenid"));
                    Log.e("QQ标识：", getIntent().getStringExtra("QQopenid"));
                }
                if (getIntent().hasExtra("WXopenid")) {
                    intent.putExtra("WXopenid", getIntent().getStringExtra("WXopenid"));
                    Log.e("微信标识：", getIntent().getStringExtra("WXopenid"));
                }
                startActivity(intent);
                this.finish();
                break;
            default:
                break;
        }
    }
}
